<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改盲盒商品')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-goods-edit" th:object="${tGoods}">
            <input name="goodsId" th:field="*{goodsId}" type="hidden">
            <input name="goodsPic" th:field="*{goodsPic}" type="hidden">
            <input name="blindboxId" th:field="*{blindboxId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品名称：</label>
                <div class="col-sm-8">
                    <input name="goodsName" th:field="*{goodsName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品图片：</label>
                <div class="col-sm-8">
                    <div class="fileinput fileinput-new" data-provides="fileinput">
                        <div class="fileinput-new thumbnail" style="width: 140px; height: 140px;">
                            <img th:src="*{goodsPic}">
                        </div>
                        <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
                        <div>
                            <span class="btn btn-white btn-file"><span class="fileinput-new">上传</span><span class="fileinput-exists">修改</span><input name="goodsPic" type="file"></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品价格：</label>
                <div class="col-sm-8">
                    <input name="goodsfee" th:field="*{goodsfee}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开出概率：</label>
                <div class="col-sm-8">
                    <input name="chance" th:field="*{chance}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">库存数：</label>
                <div class="col-sm-8">
                    <input name="stockcount" th:field="*{stockcount}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品兑换价格：</label>
                <div class="col-sm-8">
                    <input name="exchargefee" th:field="*{exchargefee}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:inline="javascript">
        var prefix = ctx + "lucky/goods";
        $("#form-goods-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-goods-edit').serialize());
            }
        }
        $('.fileinput-new').on('change.bs.fileinput ', function (e,data) {
            // 处理自己的业务
            $('input[name="goodsPic"]').val(data.result);
        });
    </script>
</body>
</html>